<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>mtlb_sort</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>M2SCI function</center>
    <div align="right">Last update : 12/10/2006</div>
    <p>
      <b>mtlb_sort</b> - Matlab sort emulation
  function</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>P = mtlb_sort(X)</tt>
      </dd>
      <dd>
        <tt>P = mtlb_sort(X,dim[,mode])</tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>X</b>
        </tt>: a scalar, vector, matrix of reals, booleans or a string</li>
    </ul>
    <ul>
      <li>
        <tt>
          <b>dim</b>
        </tt>: a positive scalar integer</li>
      <li>
        <tt>
          <b>mode</b>
        </tt>: a string ("ascend" or "descend")</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>Matlab <tt>
        <b>sort</b>
      </tt> and Scilab <tt>
        <b>gsort</b>
      </tt> behave
    differently in some particular cases:</p>
    <dl>
      <dd>
        <b></b>
        <dd>
          <li>
            <b>
              <font color="maroon"></font>
            </b>For a vector <tt>
              <b>X</b>
            </tt> the Matlab
            <tt>
              <b>sort(X,'g','i')</b>
            </tt> function call is equivalent to the
            Scilab <tt>
              <b>gsort(X)</b>
            </tt> function call.</li>
          <li>
            <b>
              <font color="maroon"></font>
            </b>The value <tt>
              <b>1</b>
            </tt> (resp. <tt>
              <b>2</b>
            </tt>) of the Matlab
            dim is equivalent to the Scilab <tt>
              <b>"r"</b>
            </tt> flag (resp.
            <tt>
              <b>"c"</b>
            </tt>).</li>
          <li>
            <b>
              <font color="maroon"></font>
            </b>The Matlab "<tt>
              <b>ascend"</b>
            </tt> (resp.
            <tt>
              <b>"descend"</b>
            </tt>) mode is equivalent to the Scilab
            <tt>
              <b>"i"</b>
            </tt> (resp. <tt>
              <b>"d"</b>
            </tt>) flag.</li>
        </dd>
      </dd>
    </dl>
    <p>The function <tt>
        <b>mtlb_sort(X[,dim[,mode]])</b>
      </tt> is used by
    <tt>
        <b>mfile2sci</b>
      </tt> to replace <tt>
        <b>sort(X[,dim[,mode]])</b>
      </tt> when
    it was not possible to know what were the inputs while porting Matlab code
    to Scilab. This function will determine the correct semantic at run time.
    If you want to have a more efficient code it is possible to replace
    <tt>
        <b>mtlb_sort</b>
      </tt> call by <a href="../elementary/gsort.htm">
        <tt>
          <b>gsort</b>
        </tt>
      </a> call.</p>
    <p>Caution: <tt>
        <b>mtlb_sort</b>
      </tt> has not to be used for hand coded
    functions.</p>
    <h3>
      <font color="blue">Authors</font>
    </h3>
    <dl>
      <dd>
        <b></b>F.B.</dd>
    </dl>
  </body>
</html>
